package com.yao.system.controller;


import com.yao.system.annotation.MyAnnotation;
import com.yao.system.entity.Company;
import com.yao.system.entity.JobCategory;
import com.yao.system.entity.Result;
import com.yao.system.service.IJobCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 霖
 * @since 2024-04-22
 */
@RestController
@RequestMapping("/job-category")
@RequiredArgsConstructor
public class JobCategoryController {

    private final IJobCategoryService jobCategoryService;

    /**
     * 查询岗位分类列表
     *
     * @return
     */
    @MyAnnotation
    @GetMapping("/list")
    public Result getList() {
        return jobCategoryService.getList();
    }

    /**
     * 新增岗位分类
     *
     * @return
     */
    @MyAnnotation
    @PostMapping("/add")
    public Result addJobCategory(@RequestBody JobCategory category) {
        jobCategoryService.save(category);
        return Result.ok("新增成功");
    }



    /**
     * 管理员查询岗位分类列表
     */
    @MyAnnotation
    @GetMapping("/admin-list/{page}/{size}")
    public Result queryCompanyList(@PathVariable("page")Integer page,
                                   @PathVariable("size")Integer size){
        return jobCategoryService.queryjobCategoryList(page,size);
    }

    /**
     * 管理员修改岗位分类信息
     */
    @MyAnnotation
    @PostMapping("/admin-update")
    public Result updateCompanyAdmin(@RequestBody JobCategory category){
        return jobCategoryService.updatejobCategoryAdmin(category);
    }

    /**
     * 管理员删除岗位分类
     */
    @MyAnnotation
    @PostMapping("/admin-delete")
    public Result deleteCompanyAdmin(@RequestBody JobCategory category){
        jobCategoryService.removeById(category);
        return Result.ok("删除成功");
    }

}
